//
//  T2ListModel.swift
//
//  Created by eme on 2017/4/10
//  Copyright (c) . All rights reserved.
//

import Foundation
import SwiftyJSON
import ModelProtocol

class T2ListModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kT2ListTitleKey: String = "title"
    internal let kT2ListUrlKey: String = "url"
    internal let kT2ListPicKey: String = "pic"
    
    
    // MARK: 属性
    var title: String
    var url: String
    var pic: String
    
    
    // MARK: 实现MikerSwiftJSONAble 协议， 解析json数据
    public required  init?(json: JSON) {
        title = json[kT2ListTitleKey].stringValue
        url = json[kT2ListUrlKey].stringValue
        pic = json[kT2ListPicKey].stringValue
        
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]
        
        dictionary.updateValue(title as AnyObject, forKey: kT2ListTitleKey)
        
        
        dictionary.updateValue(url as AnyObject, forKey: kT2ListUrlKey)
        
        
        dictionary.updateValue(pic as AnyObject, forKey: kT2ListPicKey)
        
        
        return dictionary
    }
    
    
}
